Skip to content

Conversation

honzajavorek
Copy link
Collaborator

As I progressed with #1584 I felt the code examples were starting to be more and more complex. Then I remembered that when I was young, us jQuery folks used to lean towards a naming convention where variables holding jQuery selections were prefixed with $. I changed the code examples in all lessons to adhere to this as I feel it makes them more readable and less cluttered.


ℹ️ The changes still use $.map and $.each, because they were made prior to the facb3c0 commit. It's gonna happen, but not yet.

@honzajavorek honzajavorek requested a review from gullmar August 25, 2025 19:21
@apify-service-account
Copy link

Preview for this PR was built for commit a2aa116 and is ready at https://pr-1844.preview.docs.apify.com!

@honzajavorek honzajavorek added the t-academy Issues related to Web Scraping and Apify academies. label Aug 25, 2025
@honzajavorek
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no bugs!


Comment @cursor review or bugbot run to trigger another review on this PR

const data = [];
$(".product-item").each((i, element) => {
const productItem = $(element);
const $items = $(".product-item").map((i, element) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const $items = $(".product-item").map((i, element) => {
const data = $(".product-item").toArray().map((element) => {

Adding the toArray instruction, you have a "regular" map method, that returns regular objects instead of Cheerio objects (less confusing), and you can remove the const data = $items.get(); later. Moreover, the i index was unused.

});
const data = $items.get();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const data = $items.get();

const productItem = $(element);
const item = parseProduct(productItem);
data.push(item);
const $items = $(".product-item").map((i, element) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const $items = $(".product-item").map((i, element) => {
const data = $(".product-item").toArray().map((element) => {

});
const data = $items.get();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const data = $items.get();

const data = []
$(".product-item").each((i, element) => {
const productItem = $(element);
const $items = $(".product-item").map((i, element) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const $items = $(".product-item").map((i, element) => {
const data = $(".product-item").toArray().map((element) => {

});
const data = $items.get();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const data = $items.get();

@honzajavorek
Copy link
Collaborator Author

@gullmar Thank you! 🙇‍♂️ As I mentioned in the PR description, these changes still use $.map and $.each, because they were made prior to the facb3c0 commit in my queue of work on the course. It's gonna happen, but not yet 🙏 I need to get this merged with $.map so that I can later apply that commit and make the change everywhere at once.

@honzajavorek
Copy link
Collaborator Author

I'm sorry, because it's a bit confusing and it's easy to overlook the note I made 🫠

@honzajavorek honzajavorek merged commit fc57efb into master Sep 3, 2025
10 checks passed
@honzajavorek honzajavorek deleted the honzajavorek/dollars-getting-links branch September 3, 2025 07:01
daveomri pushed a commit to daveomri/apify-docs that referenced this pull request Sep 3, 2025
As I progressed with apify#1584 I
felt the code examples were starting to be more and more complex. Then I
remembered that when I was young, us jQuery folks used to lean towards a
naming convention where variables holding jQuery selections were
prefixed with $. I changed the code examples in all lessons to adhere to
this as I feel it makes them more readable and less cluttered.

-----

ℹ️ The changes still use `$.map` and `$.each`, because they were made
prior to the facb3c0 commit. It's gonna
happen, but not yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t-academy Issues related to Web Scraping and Apify academies.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants